<template>
  <div class="learning-time-card">
    <div class="card-header">
      <span class="title">{{ title }}</span>
    </div>
    <div class="card-content">
      <div class="time-display">
        <span class="time-value">{{ learningTime }}</span>
        <span class="time-unit">min</span>
      </div>
      <div class="chart-container" v-if="showChart">
        <WordDataLine :data="chartData" />
      </div>
    </div>
  </div>
</template>

<script>
import WordDataLine from "./WordDataLine.vue";

export default {
  name: "LearningTimeCard",
  components: {
    WordDataLine,
  },
  props: {
    title: {
      type: String,
      default: "今日学习时长"
    },
    learningTime: {
      type: [Number, String],
      default: 0
    },
    chartData: {
      type: Array,
      default: () => []
    },
    showChart: {
      type: Boolean,
      default: true
    }
  }
};
</script>

<style scoped>
.learning-time-card {
  background-color: #fff;
  border-radius: 6px;
  padding: 20px;
  margin: 25px 0px 25px 25px;
  max-width: 440px;
  border-color: transparent;
  flex: 1;
  transition: box-shadow 0.3s ease;
}

.learning-time-card:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
}

.card-header {
  margin-bottom: 15px;
}

.title {
  font-size: 14px;
  color: rgb(89, 89, 89);
  margin-left: 5px;
}

.card-content {
  display: flex;
  flex-direction: column;
}

.time-display {
  padding: 5px 10px;
  margin-bottom: 15px;
}

.time-value {
  font-size: 33px;
  margin: 10px;
  color: #333;
}

.time-unit {
  font-size: 20px;
  color: #666;
}

.chart-container {
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 15px;
}

@media (max-width: 707px) {
  .learning-time-card {
    width: 100%;
    margin: 10px;
    max-width: none;
  }
}
</style>
